<template>
	<view class="userLayout pageBg" v-if="userInfo">
		<view class="userInfo">
			<view class="avatar">
				<image src="../../static/images/logo.jpg" mode="aspectFill"></image>
			</view>
			<view class="ip">{{userInfo.IP}}</view>
			<view class="address">来自:{{userInfo.address.city || userInfo.address.province || userInfo.address.country}}</view>
		</view>
		
		<view class="section">
			<view class="list">
				<navigator url="/pages/classlist/classlist?name=我的下载&type=download">
					<view class="row">
						<view class="left">
							<uni-icons type="download-filled" size="22"></uni-icons>
							<text class="text">我的下载</text>
						</view>
						<view class="right">
							<text class="text">{{userInfo.downloadSize}}</text>
							<uni-icons type="right" size="20" color="#aaa"></uni-icons>
						</view>
					</view>
				</navigator>
				
				<navigator url="/pages/classlist/classlist?name=我的评分&type=score">
					<view class="row">
						<view class="left">
							<uni-icons type="star-filled" size="22"></uni-icons>
							<text class="text">我的评分</text>
						</view>
						<view class="right">
							<text class="text">{{userInfo.scoreSize}}</text>
							<uni-icons type="right" size="20" color="#aaa"></uni-icons>
						</view>
					</view>
				</navigator>
				
				<view class="row">
					<view class="left">
						<uni-icons type="chatboxes-filled" size="22"></uni-icons>
						<text class="text">联系客服</text>
					</view>
					<view class="right">
						<uni-icons type="right" size="20" color="#aaa"></uni-icons>
					</view>
					
					<!-- #ifdef MP-WEIXIN -->
					<button open-type="contact">联系客服</button>
					<!-- #endif -->
					
					<!-- #ifndef MP-WEIXIN -->
					<button @click="phoneClick()">拨打电话</button>
					<!-- #endif -->
				</view>
			</view>
		</view>
		
		<view class="section">
			<view class="list">
				<navigator url="/pages/notice/detail?id=653507c6466d417a3718e94b">
					<view class="row">
						<view class="left">
							<uni-icons type="notification-filled" size="22"></uni-icons>
							<text class="text">订阅更新</text>
						</view>
						<view class="right">
							<uni-icons type="right" size="20" color="#aaa"></uni-icons>
						</view>
					</view>
				</navigator>
				<navigator url="/pages/notice/detail?id=6536358ce0ec19c8d67fbe82">
					<view class="row">
						<view class="left">
							<uni-icons type="flag-filled" size="22"></uni-icons>
							<text class="text">常见问题</text>
						</view>
						<view class="right">
							<uni-icons type="right" size="20" color="#aaa"></uni-icons>
						</view>
					</view>
				</navigator>
			</view>
		</view>
	</view>
		
	<view class="loadingLayout" v-else>
		<uni-load-more status="loading"></uni-load-more>
	</view>
</template>

<script setup>

import {getNavBarHeight} from '@/utils/system.js'
import {apiUserInfo} from "@/apis/apis.js"
import { ref } from 'vue';

const userInfo = ref(null)

const getUserInfo = ()=>{
	apiUserInfo().then(res=>{
		console.log(res);
		userInfo.value = res.data
	})
}
	
const phoneClick =()=>{
	uni.makePhoneCall({
		phoneNumber:"15207682442"
	})
}

getUserInfo();
</script>

<style lang="scss" scoped>
.userLayout{
	.userInfo{
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		padding: 200rpx 0 50rpx;
		.avatar{
			width: 160rpx;
			height: 160rpx;
			border-radius: 50%;
			overflow: hidden;
			image{
				width: 100%;
				height: 100%;
			}
		}
		.ip{
			font-size: 44rpx;
			padding: 5rpx 0 15rpx;
		}
		.address{
			font-size: 30rpx;
			color: #aaa;
		}
	}
	.section{
		margin-top: 50rpx;
		padding:  0 30rpx;
		.list{
			width: 690rpx;
			border: 1px solid #f6f6f6;
			box-shadow: 10rpx 10rpx 30rpx rgba(0, 0, 0, 0.1);
			.row{
				width: 100%;
				display: flex;
				justify-content: space-between;
				padding:30rpx 30rpx;
				border-bottom: 1px solid #f6f6f6;
				&:last-child{border-bottom: 0;}
				position: relative;
				background-color: #fff;
				.left{
					display: flex;
					align-items: center;
					justify-content: center;
					color: #aaa;
					font-size: 30rpx;
					:deep(){
						.uni-icons{
							color: $uni-color-brand !important;
						}
					}
					.text{
						padding-left: 15rpx;
					}
				}
				.right{
					display: flex;
					align-items: center;
					justify-content: center;
					color: #aaa;
					font-size: 30rpx;
					.text{
						padding-right: 10rpx;
					}
				}
				button{
					position: absolute;
					top: 0;
					left: 0;
					width: 100%;
					height: 100%;
					opacity: 0;
				}
			}
		}
	}
}
.loadingLayout{
	margin: 50vh 50vw;
	white-space: nowrap;
}
</style>
